package boogui.movie;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.KeyStroke;

import boogui.member.MemberVO;

public class S_MovieMenu extends JMenuBar {

	private JMenu mnMember = null;
	private JMenu mnHelp = null;
	private JSeparator separator = null;/////////////////////회원정보 수정
	private MovieActionListener mal = null;/////////////////////회원정보 수정
	
	public S_MovieMenu(JFrame p) {
		mal = new MovieActionListener(p);
		makeMenu();
		makeMenuItem();
		addShortCut();
		addMenu();
		
	}

	private void makeMenu() {
		mnMember = new JMenu(" 회 원 (M) ");
		mnHelp = new JMenu(" 도움말 (H) ");
		separator = new JSeparator();/////////////////////회원정보 수정
	}
	
	private void addShortCut() {
		mnMember.setMnemonic(KeyEvent.VK_M);		
		mnHelp.setMnemonic(KeyEvent.VK_H);
		
	}
	
	private void addMenu() {
		add(mnMember);
		add(mnHelp);
	}
	
	private JMenuItem makeMenuItems(String text, String img, int skey, boolean off, int akey) {
		String icon = null;
		if(img != null){
			icon = "/images/menu/" + img + ".png";
		}
		
		JMenuItem mnitem = null;
		try {
			mnitem = new JMenuItem(text, new ImageIcon(getClass().getResource(icon)));
		} catch (Exception ex) {
			mnitem = new JMenuItem(text);
		}
		
		mnitem.setEnabled(off);
		mnitem.setMnemonic(skey);
		mnitem.setAccelerator(KeyStroke.getKeyStroke(akey, ActionEvent.CTRL_MASK));	// 단축키				
		
		mnitem.addActionListener(mal); ///////////////////////////////// 회원정보 수정
		mnitem.setActionCommand(img);////////////////////////////////////회원정보 수정
		return mnitem;
		
		
	}
	
	private void makeMenuItem() {	
		mnMember.add(makeMenuItems("예매 정보 확인", "rcheck", KeyEvent.VK_1, true, KeyEvent.VK_1));	
		mnMember.add(separator);/////////////////////회원정보 수정
		mnMember.add(makeMenuItems("회원 정보 수정", "minfo", KeyEvent.VK_2, true, KeyEvent.VK_2));/////////////////////회원정보 수정	
		mnHelp.add(makeMenuItems("정 보 (A)", "info", KeyEvent.VK_2, true, KeyEvent.VK_2));
	
	}
}
